<template></template>
<script setup lang="ts">
const userInfoStore = useUserInfoStore();
const userInfo = uni.getStorageSync(CONSTANT_PARAMS.USER_INFO);
if (userInfo) {
  userInfoStore.setLoginInfo(userInfo.openid, userInfo.id);
  userInfoStore.setUserInfo(userInfo.nickName, userInfo.avatarUrl);
} else {
  console.log("没有信息，开始登录");

  wx.login({
    success(res) {
      userWxLogin({ code: res.code }).then((data: any) => {
        userInfoStore.setLoginInfo(data.openId, data.id);
        uni.setStorageSync(CONSTANT_PARAMS.USER_INFO, {
          openid: data.openId,
          id: data.id
        });
      });
    }
  });
}
</script>

<style lang="scss">
@import "@/styles/index.scss";
@import "uview-plus/index.scss";
</style>
